﻿using AutoMapper;
using MediatR;
using S.Eartag.API.Application.Command.MarkedConditionCommand;
using S.Eartag.Domain.Model;
using S.Eartag.Infrastructure.Impl;
using S.Eartag.Infrastructure.Interface;

namespace S.Eartag.API.Application.CommandHandlers.MarkedConditionCommandHandler
{
    public class MarkedConditionDeleteCommandHandler : IRequestHandler<MarkedConditionDeleteCommand, int>
    {
        private readonly IMarkRepository markRepository;
        private readonly IMapper mapper;

        public MarkedConditionDeleteCommandHandler(IMarkRepository markRepository, IMapper mapper)
        {
            this.markRepository = markRepository;
            this.mapper = mapper;
        }

        public async Task<int> Handle(MarkedConditionDeleteCommand request, CancellationToken cancellationToken)
        {
            var res = await markRepository.Get(request.id);
            res.IsDel = true;
            var info = markRepository.Update(res);
            return await info;
        }
    }
}
